package com.singleton;

/**
 * 懒汉式
 */
public class Singleton4 {
    private Singleton4() {
    }

    public static final Singleton4 getInstance(){
           return SingletonInstance.INSTANCE;

    }

    static  class  SingletonInstance{
        public static final Singleton4 INSTANCE=new Singleton4();
    }
}

class testSingleton4{
    public static void main(String[] args) {
        for (int i = 0; i < 3; i++) {
            new Thread(new Runnable() {
                @Override
                public void run() {
                    System.out.println(Singleton4.getInstance().hashCode());
                }
            }).start();
        }
    }
}